<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>简单选择</title>
</head>
<body>
  <p id="p1"><b>Hello</b> world!</p>

  <script>
    const range1 = document.createRange(),
          range2 = document.createRange(),
          p1 = document.getElementById('p1');
    range1.selectNode(p1);
    range2.selectNode(p1);
  </script>
</body>
</html>